﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynaPrecision.LinearSystem
{
	public class MappedMultiDimensionalArray<TSource, TData> : IMultiDimensionalArray<TData>
	{
		public TSource Source { get; set; }
		public List<int> _lengths;
		public List<int> Lengths
		{
			get
			{
				return _lengths;
			}
		}
		public Action<TSource, int[], TData> Setter { get; set; }
		public Func<TSource, int[], TData> Getter { get; set; }



		#region IMultiDimensionalArray<TInput> Members

		public TData this[params int[] index]
		{
			get
			{
				return Getter(Source, index);
			}
			set
			{
				Setter(Source, index, value);
			}
		}

		public int GetLength(int DimensinNumber)
		{
			if (DimensinNumber >= Dimension)
			{
				return 0;
			}
			else
			{
				return Lengths[DimensinNumber];
			}
		}

		public int Dimension
		{
			get
			{
				return Lengths.Count;
			}
		}

		#endregion
	}
}
